% =========================================================================
% Schniepp Lab, 2018-2021
% The first part to carry out the unpolarized Raman spectra fitting
% Steps:
% 1. Import the model polypeptide digitized spectra from csv files
% 2. Remove data outliers in the digitized spectra
% =========================================================================

% =========================================================================
% 1. Import the model polypeptide digitized spectra from csv files
% =========================================================================
% Initialize the MATLAB workspace
clear;

% alpha - Poly-alanine
% Var: Unpolar_Raman_aPA_Fanconi1973
Unpolar_Raman_aPA_Fanconi1973 = csvread('./Temp/aPA.csv',1,0);

% beta - Poly-alanine
% Var: Unpolar_Raman_bPA
Unpolar_Raman_bPA = csvread('./Temp/bPA.csv',1,0);

% Glycine - I
% Var: Unpolar_AmideI_Raman_GlyI
Unpolar_AmideI_Raman_GlyI = csvread('./Temp/GlyI.csv',1,0);

% Glycine - II
% Var: Unpolar_AmideI_Raman_GlyII
Unpolar_AmideI_Raman_GlyII = csvread('./Temp/GlyII.csv',1,0);

% Reset the zero Raman signal count
Unpolar_Raman_aPA_Fanconi1973_P = Unpolar_Raman_aPA_Fanconi1973;
Unpolar_Raman_aPA_Fanconi1973_P(:,2) = Unpolar_Raman_aPA_Fanconi1973(:,2) - min(Unpolar_Raman_aPA_Fanconi1973(:,2));

Unpolar_Raman_bPA_P = Unpolar_Raman_bPA;
Unpolar_Raman_bPA_P(:,2) = Unpolar_Raman_bPA(:,2) - min(Unpolar_Raman_bPA(:,2));

Unpolar_AmideI_Raman_GlyI_P = Unpolar_AmideI_Raman_GlyI;
Unpolar_AmideI_Raman_GlyI_P(:,2) = Unpolar_AmideI_Raman_GlyI(:,2) - min(Unpolar_AmideI_Raman_GlyI(:,2));

Unpolar_AmideI_Raman_GlyII_P = Unpolar_AmideI_Raman_GlyII;
Unpolar_AmideI_Raman_GlyII_P(:,2) = Unpolar_AmideI_Raman_GlyII(:,2) - min(Unpolar_AmideI_Raman_GlyII(:,2));

% =========================================================================
% 2. Remove data outliers in the digitized spectra
% =========================================================================

% The quickPlot function plots the spectra in MATLAB interactive figure
% panels. First link the data to the correct variable, and then use the
% brush tool to remove the data outliers (the localized sharp peaks)

% alpha - Poly-alanine: the digitized data is pretty clean, no need to
% brush

% beta - Poly-alanine
quickPlot('a',Unpolar_Raman_bPA_P);
title('beta Poly-Alanine, Raman');

% Glycine - I
quickPlot('a',Unpolar_AmideI_Raman_GlyI_P);
title('Glycine I, Raman');

% Glycine - II
quickPlot('a',Unpolar_AmideI_Raman_GlyII_P);
title('Glycine II, Raman');

% Now we need to manually save the variables into a MATLAB data file (.mat)
% This data file will be used in the second part of the script.

% save('./Data/Cleaned Polypeptide Data.mat');